﻿using System;
using System.Collections;
using System.Collections.Generic;
using Assets.Scripts.GtsScripts;
using UnityEngine;

// Token: 0x0200029B RID: 667
public class PlayerRaygun : PlayerGun
{
	// Token: 0x06000ECB RID: 3787 RVA: 0x00071078 File Offset: 0x0006F278
	private void Start()
	{
		this.currentFiringMode = PlayerRaygun.FiringMode.SingleFire;
		this.rb.detectCollisions = false;
		this.SetupMasks();
		this.growColor = new Color(GlobalPreferences.GrowColorR.value, GlobalPreferences.GrowColorG.value, GlobalPreferences.GrowColorB.value);
		this.shrinkColor = new Color(GlobalPreferences.ShrinkColorR.value, GlobalPreferences.ShrinkColorG.value, GlobalPreferences.ShrinkColorB.value);
		this.activeColor = this.growColor;
		this.line.positionCount = 3;
		this.line.enabled = false;
		this.line.startWidth = this.baseLineStartWidth;
		this.line.endWidth = this.baseLineEndWidth;
		this.aimTargetObj = new GameObject();
		this.aimTargetObj.name = "Aim Target";
		this.RefreshColors();
		base.transform.localScale = new Vector3(0.08f, 0.08f, 0.08f);
		PlayerRaygun.instance = this;
	}

	// Token: 0x06000ECC RID: 3788 RVA: 0x0007117C File Offset: 0x0006F37C
	private void OnEnable()
	{
		if (this.reticuleUIObj != null)
		{
			this.reticuleUIObj.SetActive(true);
		}
		else
		{
			this.reticuleUIObj = UnityEngine.Object.Instantiate<GameObject>(Resources.Load<GameObject>("Raygun/UI/raygun_reticule"));
			this.reticuleUI = this.reticuleUIObj.GetComponent<RaygunReticule>();
		}
	}

	// Token: 0x06000ECD RID: 3789 RVA: 0x000711D1 File Offset: 0x0006F3D1
	private void OnDisable()
	{
		this.StopFiring();
		if (this.reticuleUIObj != null)
		{
			this.reticuleUIObj.SetActive(false);
		}
	}

	// Token: 0x06000ECE RID: 3790 RVA: 0x000711F6 File Offset: 0x0006F3F6
	private void OnDestroy()
	{
		UnityEngine.Object.Destroy(this.reticuleUI.gameObject);
	}

	// Token: 0x06000ECF RID: 3791 RVA: 0x00071208 File Offset: 0x0006F408
	public void SetupMasks()
	{
		this.aimMask = Layers.raygunAimMask;
		this.SetupProjectileMask();
		this.SetupLaserMask();
		this.SetupSonicMask();
	}

	// Token: 0x06000ED0 RID: 3792 RVA: 0x00071228 File Offset: 0x0006F428
	public void SetupProjectileMask()
	{
		List<string> list = new List<string>();
		list.Add(LayerMask.LayerToName(Layers.mapLayer));
		if (GlobalPreferences.PlayerProjectileGtsMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.gtsBodyLayer));
		}
		if (GlobalPreferences.PlayerProjectileMicroMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.microLayer));
		}
		if (GlobalPreferences.PlayerProjectileObjectMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.objectLayer));
		}
		this.projectileMask = LayerMask.GetMask(list.ToArray());
	}

	// Token: 0x06000ED1 RID: 3793 RVA: 0x000712C0 File Offset: 0x0006F4C0
	public void SetupLaserMask()
	{
		List<string> list = new List<string>();
		list.Add(LayerMask.LayerToName(Layers.mapLayer));
		if (GlobalPreferences.LaserGtsMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.gtsBodyLayer));
		}
		if (GlobalPreferences.LaserMicroMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.microLayer));
		}
		if (GlobalPreferences.LaserObjectMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.objectLayer));
		}
		this.laserMask = LayerMask.GetMask(list.ToArray());
	}

	// Token: 0x06000ED2 RID: 3794 RVA: 0x00071358 File Offset: 0x0006F558
	public void SetupSonicMask()
	{
		List<string> list = new List<string>();
		if (GlobalPreferences.SonicGtsMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.gtsBodyLayer));
		}
		if (GlobalPreferences.SonicMicroMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.microLayer));
		}
		if (GlobalPreferences.SonicObjectMask.value)
		{
			list.Add(LayerMask.LayerToName(Layers.objectLayer));
		}
		this.sonicMask = LayerMask.GetMask(list.ToArray());
	}

	// Token: 0x06000ED3 RID: 3795 RVA: 0x000713E0 File Offset: 0x0006F5E0
	private void Update()
	{
		if (GameController.Instance.paused)
		{
			return;
		}
		if (GameController.playerInstance != null)
		{
			this.playerScale = GameController.playerInstance.transform.localScale.x;
		}
		if (this.isFiring)
		{
			PlayerRaygun.FiringMode firingMode = this.currentFiringMode;
			if (firingMode != PlayerRaygun.FiringMode.SingleFire)
			{
				if (firingMode != PlayerRaygun.FiringMode.Continuous)
				{
					if (firingMode == PlayerRaygun.FiringMode.Sonic)
					{
						this.FireSonic();
					}
				}
				else
				{
					this.FireContinuousLaser();
				}
			}
			else
			{
				this.ChargeProjectile();
			}
		}
		if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
		{
			this.UpdateUtilityInput();
		}
		else
		{
			this.UpdatePolarityInput();
		}
	}

	// Token: 0x06000ED4 RID: 3796 RVA: 0x000714A8 File Offset: 0x0006F6A8
	private void FixedUpdate()
	{
		if (this.currentFiringMode == PlayerRaygun.FiringMode.Sonic && this.isFiring)
		{
			foreach (KeyValuePair<Transform, int> keyValuePair in this.sonicAffectedRootTransforms)
			{
				this.AffectSonicObject(keyValuePair.Key);
			}
		}
	}

	// Token: 0x06000ED5 RID: 3797 RVA: 0x00071524 File Offset: 0x0006F724
	private void UpdatePolarityInput()
	{
		float num = Input.GetAxisRaw(ButtonInput.RaygunUtility) / 2f;
		if (Input.GetButton(ButtonInput.RaygunUtilityPos))
		{
			num += 0.05f;
		}
		else if (Input.GetButton(ButtonInput.RaygunUtilityNeg))
		{
			num -= 0.05f;
		}
		if (num != 0f)
		{
			this.polarityMagnitude = Mathf.Clamp(this.polarityMagnitude + num, -1f, 1f);
			this.reticuleUI.ChangePolarityValue(this.polarityMagnitude);
			this.activeColor = ((this.polarityMagnitude >= 0f) ? this.growColor : this.shrinkColor);
			this.UpdateGradient();
			this.UpdateChamberColor();
			if (this.currentFiringMode == PlayerRaygun.FiringMode.Continuous)
			{
				this.UpdateLaserAlpha();
			}
			this.PlayAuxiliarySound(SoundManager.This.playerRaygunPolaritySound);
		}
	}

	// Token: 0x06000ED6 RID: 3798 RVA: 0x00071604 File Offset: 0x0006F804
	private void UpdateUtilityInput()
	{
		float num = Input.GetAxisRaw(ButtonInput.RaygunUtility) * 5f;
		if (Input.GetButtonUp(ButtonInput.RaygunUtilityPos))
		{
			num += 0.5f;
		}
		else if (Input.GetButtonUp(ButtonInput.RaygunUtilityNeg))
		{
			num -= 0.5f;
		}
		if (num != 0f)
		{
			PlayerRaygun.FiringMode firingMode = this.currentFiringMode;
			if (firingMode != PlayerRaygun.FiringMode.SingleFire)
			{
				if (firingMode != PlayerRaygun.FiringMode.Continuous)
				{
					if (firingMode == PlayerRaygun.FiringMode.Sonic)
					{
						GlobalPreferences.SonicWidth.value = Mathf.Clamp(GlobalPreferences.SonicWidth.value + num, 0.5f, 3f);
						this.SetupParticlesForSonicFire();
					}
				}
				else
				{
					GlobalPreferences.LaserWidth.value = Mathf.Clamp(GlobalPreferences.LaserWidth.value + num, 0.5f, 15f);
				}
			}
			else
			{
				GlobalPreferences.PlayerProjectileSpeed.value = Mathf.Clamp(GlobalPreferences.PlayerProjectileSpeed.value + num / 2f, 0.25f, 3f);
			}
			this.PlayAuxiliarySound(SoundManager.This.playerRaygunModeSwitchSound);
		}
	}

	// Token: 0x06000ED7 RID: 3799 RVA: 0x0007171C File Offset: 0x0006F91C
	public void RefreshColors()
	{
		if (!this.scriptGrowColor.Equals(Color.clear) && GlobalPreferences.RaygunScriptMode.value)
		{
			this.growColor = this.scriptGrowColor;
		}
		else
		{
			this.growColor = new Color(GlobalPreferences.GrowColorR.value, GlobalPreferences.GrowColorG.value, GlobalPreferences.GrowColorB.value);
		}
		if (!this.scriptShrinkColor.Equals(Color.clear) && GlobalPreferences.RaygunScriptMode.value)
		{
			this.shrinkColor = this.scriptShrinkColor;
		}
		else
		{
			this.shrinkColor = new Color(GlobalPreferences.ShrinkColorR.value, GlobalPreferences.ShrinkColorG.value, GlobalPreferences.ShrinkColorB.value);
		}
		this.activeColor = ((this.polarityMagnitude >= 0f) ? this.growColor : this.shrinkColor);
		this.UpdateGradient();
		this.UpdateChamberColor();
	}

	// Token: 0x06000ED8 RID: 3800 RVA: 0x0007182E File Offset: 0x0006FA2E
	public void RefreshUI()
	{
		this.reticuleUI.SetupUI();
	}

	// Token: 0x06000ED9 RID: 3801 RVA: 0x0007183B File Offset: 0x0006FA3B
	public void ResetUIFade()
	{
		this.reticuleUI.ResetFade();
	}

	// Token: 0x06000EDA RID: 3802 RVA: 0x00071848 File Offset: 0x0006FA48
	public void ChangeAuxiliaryUIColor(Color color)
	{
		this.reticuleUI.ChangeAuxiliaryColor(color);
	}

	// Token: 0x06000EDB RID: 3803 RVA: 0x00071856 File Offset: 0x0006FA56
	public void SetCamera(Camera camera)
	{
		this.mainCamera = camera;
	}

	// Token: 0x06000EDC RID: 3804 RVA: 0x00071860 File Offset: 0x0006FA60
	public Transform GetAimTargetTransform()
	{
		if (this.aimTargetObj == null)
		{
			return null;
		}
		Ray ray = this.mainCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
		RaycastHit raycastHit;
		if (Physics.Raycast(ray, out raycastHit, 1000000f, this.aimMask))
		{
			this.aimTargetObj.transform.position = raycastHit.point;
		}
		else
		{
			this.aimTargetObj.transform.position = ray.GetPoint(1000f * this.playerScale);
		}
		return this.aimTargetObj.transform;
	}

	// Token: 0x06000EDD RID: 3805 RVA: 0x00071908 File Offset: 0x0006FB08
	public void StartFiring()
	{
		if (!this.scriptEnableRaygun && GlobalPreferences.RaygunScriptMode.value)
		{
			return;
		}
		PlayerRaygun.FiringMode firingMode = this.currentFiringMode;
		if (firingMode != PlayerRaygun.FiringMode.SingleFire)
		{
			if (firingMode != PlayerRaygun.FiringMode.Continuous)
			{
				if (firingMode == PlayerRaygun.FiringMode.Sonic)
				{
					this.sonicAffectedObjects.Clear();
					this.sonicAffectedRootTransforms.Clear();
					this.SetupParticlesForSonicFire();
					this.SetupSoundsForSonic();
				}
			}
			else
			{
				this.SetupParticlesForLaser();
				this.SetupSoundsForLaser();
			}
		}
		else
		{
			this.currentCharge = 8f;
			this.SetupParticlesForSingleFire();
			this.SetupSoundsForProjectile();
		}
		this.isFiring = true;
		EventManager.SendEvent(new PlayerTriggerPressEvent());
	}

	// Token: 0x06000EDE RID: 3806 RVA: 0x000719B8 File Offset: 0x0006FBB8
	private void ChargeProjectile()
	{
		this.emitterParticles.transform.localScale = Vector3.one * this.playerScale;
		if (this.emitterParticles.isStopped)
		{
			this.emitterParticles.Play();
			this.chargeParticles.Play();
		}
		this.currentCharge = Mathf.Lerp(this.currentCharge, 1f, Time.deltaTime / 2f * GlobalPreferences.ProjectileChargeRate.value);
		this.emitterParticles.main.startLifetime = new ParticleSystem.MinMaxCurve(this.currentCharge);
	}

	// Token: 0x06000EDF RID: 3807 RVA: 0x00071A58 File Offset: 0x0006FC58
	private void FireProjectile()
	{
		float num = 6f / this.currentCharge * 4f;
		Vector3 position = this.firingPoint.position + this.firingPoint.forward * num / 5f * this.playerScale;
		GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.projectilePrefab, position, base.transform.rotation);
		PlayerRaygunProjectile component = gameObject.GetComponent<PlayerRaygunProjectile>();
		component.Initialize(this.polarityMagnitude, num, this.activeColor, this.projectileMask, this.playerScale);
		this.emitterParticles.Stop();
		this.chargeParticles.Stop();
		this.chargeParticles.Clear();
		if (!this.firstPersonMode)
		{
			this.shotEmitterParticles.transform.localScale = Vector3.one * this.playerScale;
			this.shotEmitterParticles.Emit(20);
		}
		this.firingAudioSource1.volume = 1f;
		this.firingAudioSource1.Play();
	}

	// Token: 0x06000EE0 RID: 3808 RVA: 0x00071B64 File Offset: 0x0006FD64
	private void FireContinuousLaser()
	{
		this.emitterParticles.transform.localScale = Vector3.one * this.playerScale;
		if (this.emitterParticles.isStopped && !this.firstPersonMode)
		{
			this.emitterParticles.Play();
		}
		this.firingAudioSource2.volume = Mathf.Abs(this.polarityMagnitude * 0.67f) + 0.33f;
		if (!this.line.enabled)
		{
			this.firingAudioSource2.Play();
		}
		Ray ray = this.mainCamera.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
		RaycastHit raycastHit;
		Vector3 point;
		if (Physics.Raycast(ray, out raycastHit, 1000000f, this.laserMask))
		{
			point = raycastHit.point;
			GameObject gameObject = raycastHit.transform.gameObject;
			float num = 0.25f;
			if (gameObject.layer == Layers.gtsBodyLayer)
			{
				Giantess giantess = gameObject.GetComponent<GiantessBone>().giantess;
				gameObject = giantess.gameObject;
				num = 10f * Mathf.Log(gameObject.transform.localScale.x + 1f, 2f);
			}
			else if (gameObject.layer == Layers.objectLayer)
			{
				GiantessBone component = gameObject.GetComponent<GiantessBone>();
				if (component != null)
				{
					gameObject = component.giantess.gameObject;
					num = 10f * Mathf.Log(gameObject.transform.localScale.x + 1f, 2f);
				}
				else
				{
					gameObject = gameObject.transform.parent.gameObject;
				}
			}
			if (gameObject.layer != Layers.mapLayer)
			{
				if (!GlobalPreferences.RaygunScriptMode.value)
				{
					ResizeManager resizeManager = gameObject.GetComponent<ResizeManager>() ?? gameObject.AddComponent<ResizeManager>();
					ResizeManager.Resizer resizer = new ResizeManager.Resizer(0.1f, 0.01f * this.polarityMagnitude * GlobalPreferences.LaserEffectMultiplier.value, false);
					resizeManager.AddResizer(resizer);
				}
				else
				{
					EventManager.SendEvent(new PlayerRaygunHitEvent(gameObject.GetComponent<EntityBase>(), this.polarityMagnitude, 1, 0f));
				}
			}
			if (GlobalPreferences.LaserImpactParticles.value)
			{
				this.impactParticlesObj.transform.position = point;
				float num2 = 10f * Mathf.Log(GlobalPreferences.LaserWidth.value + 1f, 6f) * num * GlobalPreferences.LaserImpactParticlesSizeMult.value;
				this.impactParticlesObj.transform.localScale = new Vector3(num2, num2, num2);
				if (this.impactParticles.isStopped)
				{
					this.impactParticles.Play();
				}
			}
		}
		else
		{
			point = ray.GetPoint(1000f * this.playerScale);
			if (this.impactParticles.isPlaying)
			{
				this.impactParticles.Stop();
				this.impactParticles.Clear();
			}
		}
		this.line.enabled = true;
		this.line.startWidth = this.baseLineStartWidth * this.playerScale * GlobalPreferences.LaserWidth.value;
		this.line.endWidth = this.baseLineEndWidth * this.playerScale * GlobalPreferences.LaserWidth.value;
		this.line.SetPosition(0, this.firingPoint.position);
		float num3 = Vector3.Magnitude(point - this.firingPoint.position);
		Vector3 a;
		if (num3 < 5f)
		{
			a = Vector3.Normalize(point - this.firingPoint.position) * 0.96f * this.playerScale;
		}
		else if (num3 < 100f)
		{
			a = (point - this.firingPoint.position) * (4f + GlobalPreferences.LaserWidth.value) / 100f * this.playerScale;
		}
		else
		{
			a = Vector3.Normalize(point - this.firingPoint.position) * (5f + GlobalPreferences.LaserWidth.value) * this.playerScale;
		}
		Vector3 position = a + this.firingPoint.position;
		this.line.SetPosition(1, position);
		this.line.SetPosition(2, point);
	}

	// Token: 0x06000EE1 RID: 3809 RVA: 0x00071FD2 File Offset: 0x000701D2
	private void ClearLaser()
	{
		this.impactParticles.Stop();
		this.emitterParticles.Stop();
		this.line.enabled = false;
		this.firingAudioSource2.Stop();
	}

	// Token: 0x06000EE2 RID: 3810 RVA: 0x00072004 File Offset: 0x00070204
	private void FireSonic()
	{
		this.sonicParticles.transform.localScale = Vector3.one * this.playerScale;
		this.emitterParticles.transform.localScale = Vector3.one * this.playerScale;
		if (this.emitterParticles.isStopped && !this.firstPersonMode)
		{
			this.emitterParticles.Play();
		}
		this.firingAudioSource2.volume = Mathf.Abs(this.polarityMagnitude * 0.67f) + 0.33f;
		if (this.sonicParticles.isStopped)
		{
			this.sonicParticles.Play();
			this.firingAudioSource1.volume = Mathf.Abs(this.polarityMagnitude * 0.67f) + 0.33f;
			this.firingAudioSource1.Play();
			this.firingAudioSource2.Play();
		}
		if (!this.rb.detectCollisions)
		{
			base.StartCoroutine(this.ActivateSonicFrustrum());
		}
	}

	// Token: 0x06000EE3 RID: 3811 RVA: 0x0007210C File Offset: 0x0007030C
	private IEnumerator ActivateSonicFrustrum()
	{
		this.checkCurrentObjectsInFrustrum = true;
		if (this.currentFiringMode == PlayerRaygun.FiringMode.Sonic && this.isFiring)
		{
			this.rb.detectCollisions = true;
		}
		yield return null;
		yield return null;
		yield return null;
		this.checkCurrentObjectsInFrustrum = false;
		yield break;
	}

	// Token: 0x06000EE4 RID: 3812 RVA: 0x00072128 File Offset: 0x00070328
	private void ClearSonic()
	{
		this.sonicParticles.Stop();
		this.sonicParticles.Clear();
		this.emitterParticles.Stop();
		this.rb.detectCollisions = false;
		this.checkCurrentObjectsInFrustrum = false;
		this.firingAudioSource2.Stop();
	}

	// Token: 0x06000EE5 RID: 3813 RVA: 0x00072174 File Offset: 0x00070374
	private void OnTriggerStay(Collider collider)
	{
		if (!this.checkCurrentObjectsInFrustrum)
		{
			return;
		}
		this.OnTriggerEnter(collider);
	}

	// Token: 0x06000EE6 RID: 3814 RVA: 0x0007218C File Offset: 0x0007038C
	private void OnTriggerEnter(Collider collider)
	{
		GameObject gameObject = collider.gameObject;
		Transform root = collider.transform.root;
		if ((this.sonicMask.value & 1 << gameObject.layer) != 1 << gameObject.layer || gameObject.layer == Layers.playerLayer)
		{
			return;
		}
		if (!this.sonicAffectedObjects.Contains(gameObject))
		{
			this.sonicAffectedObjects.Add(gameObject);
			if (this.sonicAffectedRootTransforms.ContainsKey(root))
			{
				if (!GlobalPreferences.SonicTagging.value)
				{
					this.sonicAffectedRootTransforms[root] = this.sonicAffectedRootTransforms[root] + 1;
				}
			}
			else
			{
				this.sonicAffectedRootTransforms.Add(root, 1);
			}
		}
	}

	// Token: 0x06000EE7 RID: 3815 RVA: 0x00072250 File Offset: 0x00070450
	private void OnTriggerExit(Collider collider)
	{
		GameObject gameObject = collider.gameObject;
		Transform root = collider.transform.root;
		if ((this.sonicMask.value & 1 << gameObject.layer) != 1 << gameObject.layer || gameObject.layer == Layers.playerLayer)
		{
			return;
		}
		if (this.sonicAffectedObjects.Contains(gameObject))
		{
			this.sonicAffectedObjects.Remove(gameObject);
			if (GlobalPreferences.SonicTagging.value)
			{
				return;
			}
			if (this.sonicAffectedRootTransforms.ContainsKey(root) && this.sonicAffectedRootTransforms[root] > 1)
			{
				this.sonicAffectedRootTransforms[root] = this.sonicAffectedRootTransforms[root] - 1;
			}
			else
			{
				this.sonicAffectedRootTransforms.Remove(root);
			}
		}
	}

	// Token: 0x06000EE8 RID: 3816 RVA: 0x00072328 File Offset: 0x00070528
	private void AffectSonicObject(Transform target)
	{
		float num = 0.25f;
		GameObject gameObject = target.gameObject;
		if (this.aimTargetObj.GetComponent<Giantess>() != null)
		{
			num = 2.5f * Mathf.Log(this.aimTargetObj.transform.localScale.x + 1f, 2f);
		}
		if (!GlobalPreferences.RaygunScriptMode.value)
		{
			ResizeManager resizeManager = gameObject.GetComponent<ResizeManager>() ?? gameObject.AddComponent<ResizeManager>();
			ResizeManager.Resizer resizer = new ResizeManager.Resizer(0.1f, 0.01f * this.polarityMagnitude * GlobalPreferences.SonicEffectMultiplier.value * num, false);
			resizeManager.AddResizer(resizer);
		}
		else
		{
			EventManager.SendEvent(new PlayerRaygunHitEvent(gameObject.GetComponent<EntityBase>(), this.polarityMagnitude, 2, 0f));
		}
	}

	// Token: 0x06000EE9 RID: 3817 RVA: 0x000723FC File Offset: 0x000705FC
	public void StopFiring()
	{
		if (this.isFiring)
		{
			PlayerRaygun.FiringMode firingMode = this.currentFiringMode;
			if (firingMode != PlayerRaygun.FiringMode.SingleFire)
			{
				if (firingMode != PlayerRaygun.FiringMode.Continuous)
				{
					if (firingMode == PlayerRaygun.FiringMode.Sonic)
					{
						this.sonicAffectedObjects.Clear();
						this.sonicAffectedRootTransforms.Clear();
						this.ClearSonic();
					}
				}
				else
				{
					this.ClearLaser();
				}
			}
			else
			{
				this.FireProjectile();
			}
		}
		this.isFiring = false;
		EventManager.SendEvent(new PlayerTriggerReleaseEvent());
	}

	// Token: 0x06000EEA RID: 3818 RVA: 0x0007247C File Offset: 0x0007067C
	public void SwitchFiringMode()
	{
		this.StopFiring();
		if (this.currentFiringMode != PlayerRaygun.FiringMode.Sonic)
		{
			this.currentFiringMode++;
		}
		else
		{
			this.currentFiringMode = PlayerRaygun.FiringMode.SingleFire;
		}
		this.reticuleUI.ChangeFiringMode((int)this.currentFiringMode);
		this.PlayAuxiliarySound(SoundManager.This.playerRaygunModeSwitchSound);
	}

	// Token: 0x06000EEB RID: 3819 RVA: 0x000724D8 File Offset: 0x000706D8
	private void UpdateChamberColor()
	{
		Material[] materials = this.modelMeshRenderer.materials;
		Material material = UnityEngine.Object.Instantiate<Material>(materials[6]);
		material.SetColor("_Color", this.activeColor);
		Vector4 v = new Vector4(this.activeColor.r, this.activeColor.g, this.activeColor.b, 0f) * (Mathf.Abs(this.polarityMagnitude) * 3f);
		material.SetColor("_EmissionColor", v);
		materials[6] = material;
		this.modelMeshRenderer.materials = materials;
	}

	// Token: 0x06000EEC RID: 3820 RVA: 0x00072570 File Offset: 0x00070770
	private void UpdateGradient()
	{
		float num = Mathf.Abs(this.polarityMagnitude);
		this.laserLineGradient.SetKeys(new GradientColorKey[]
		{
			new GradientColorKey(Color.clear, 0f),
			new GradientColorKey(this.activeColor, 0.1f),
			new GradientColorKey(this.activeColor, 0.96f),
			new GradientColorKey(Color.clear, 1f)
		}, new GradientAlphaKey[]
		{
			new GradientAlphaKey(0f, 0f),
			new GradientAlphaKey(1f, 1f)
		});
		this.line.colorGradient = this.laserLineGradient;
		this.laserParticlesGradient.SetKeys(new GradientColorKey[]
		{
			new GradientColorKey(Color.clear, 0f),
			new GradientColorKey(this.activeColor, 0.5f),
			new GradientColorKey(Color.clear, 1f)
		}, new GradientAlphaKey[]
		{
			new GradientAlphaKey(0f, 0f),
			new GradientAlphaKey(1f * num, 0.4f),
			new GradientAlphaKey(1f * num, 0.7f),
			new GradientAlphaKey(0f, 1f)
		});
		this.singleFireEmitterParticlesGradient.SetKeys(new GradientColorKey[]
		{
			new GradientColorKey(this.activeColor, 0f)
		}, new GradientAlphaKey[]
		{
			new GradientAlphaKey(1f, 0f)
		});
		this.sonicParticlesGradient.SetKeys(new GradientColorKey[]
		{
			new GradientColorKey(this.activeColor, 0f),
			new GradientColorKey(this.activeColor, 1f)
		}, new GradientAlphaKey[]
		{
			new GradientAlphaKey(0f, 0f),
			new GradientAlphaKey(Mathf.Clamp(0.7f * num, 0.005f, 2f), 0.1f),
			new GradientAlphaKey(Mathf.Clamp(0.3f * num, 0.001f, 2f), 0.85f),
			new GradientAlphaKey(0f, 1f)
		});
		this.emitterParticles.colorOverLifetime.color = this.activeEmitterParticlesGradient;
		this.chargeParticles.colorOverLifetime.color = this.activeEmitterParticlesGradient;
		this.impactParticles.colorOverLifetime.color = this.laserParticlesGradient;
		this.sonicParticles.colorOverLifetime.color = this.sonicParticlesGradient;
	}

	// Token: 0x06000EED RID: 3821 RVA: 0x000728D4 File Offset: 0x00070AD4
	private void UpdateLaserAlpha()
	{
		Material material = UnityEngine.Object.Instantiate<Material>(this.line.material);
		material.SetFloat("_alpha", Mathf.Abs(this.polarityMagnitude));
		this.line.material = material;
	}

	// Token: 0x06000EEE RID: 3822 RVA: 0x00072914 File Offset: 0x00070B14
	private void SetupParticlesForLaser()
	{
		this.activeEmitterParticlesGradient = this.laserParticlesGradient;
		this.emitterParticles.colorOverLifetime.color = this.activeEmitterParticlesGradient;
		this.emitterParticles.sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, this.expandingCurve);
		this.emitterParticles.emission.rateOverTime = 2f;
		ParticleSystem.MainModule main = this.emitterParticles.main;
		main.maxParticles = 50;
		main.startLifetime = new ParticleSystem.MinMaxCurve(1f, 1.5f);
		main.startSize = new ParticleSystem.MinMaxCurve(0.3f, 1f);
	}

	// Token: 0x06000EEF RID: 3823 RVA: 0x000729CC File Offset: 0x00070BCC
	private void SetupParticlesForSingleFire()
	{
		this.activeEmitterParticlesGradient = this.singleFireEmitterParticlesGradient;
		this.emitterParticles.colorOverLifetime.color = this.activeEmitterParticlesGradient;
		this.shotEmitterParticles.colorOverLifetime.color = this.activeEmitterParticlesGradient;
		this.chargeParticles.colorOverLifetime.color = this.activeEmitterParticlesGradient;
		this.chargeParticles.main.duration = 4f / GlobalPreferences.ProjectileChargeRate.value;
		this.emitterParticles.sizeOverLifetime.size = new ParticleSystem.MinMaxCurve(1f, this.retractingCurve);
		this.emitterParticles.emission.rateOverTime = 0.5f;
		ParticleSystem.MainModule main = this.emitterParticles.main;
		main.maxParticles = 1;
		main.startLifetime = new ParticleSystem.MinMaxCurve(8f);
		main.startSize = new ParticleSystem.MinMaxCurve(1f);
	}

	// Token: 0x06000EF0 RID: 3824 RVA: 0x00072AD8 File Offset: 0x00070CD8
	private void SetupParticlesForSonicFire()
	{
		this.sonicParticles.colorOverLifetime.color = this.sonicParticlesGradient;
		AnimationCurve animationCurve = new AnimationCurve();
		animationCurve.AddKey(0f, 0.25f);
		animationCurve.AddKey(1f, 7f);
		ParticleSystem.SizeOverLifetimeModule sizeOverLifetime = this.sonicParticles.sizeOverLifetime;
		sizeOverLifetime.x = new ParticleSystem.MinMaxCurve(GlobalPreferences.SonicWidth.value, animationCurve);
		sizeOverLifetime.y = new ParticleSystem.MinMaxCurve(GlobalPreferences.SonicWidth.value, animationCurve);
		sizeOverLifetime.z = new ParticleSystem.MinMaxCurve(5f);
		this.sonicParticles.emission.rateOverTime = 12f;
		ParticleSystem.MainModule main = this.sonicParticles.main;
		main.maxParticles = (int)(2000f * this.sonicLengthMult);
		main.startLifetime = new ParticleSystem.MinMaxCurve(3f * this.sonicLengthMult);
		main.startSize = new ParticleSystem.MinMaxCurve(50f);
		main.startSpeed = new ParticleSystem.MinMaxCurve(12f);
		if (GlobalPreferences.SonicWidth.value <= 1f)
		{
			this.sonicCollider.radius = 5f + GlobalPreferences.SonicWidth.value * 30f;
			this.sonicCollider.height = 240f;
			this.sonicCollider.center = new Vector3(0f, 1f, 135f);
		}
		else
		{
			this.sonicCollider.radius = this.baseSonicColliderRadius * (GlobalPreferences.SonicWidth.value - 0.75f);
			if (GlobalPreferences.SonicWidth.value > 2f)
			{
				this.sonicCollider.height = 290f;
				this.sonicCollider.center = new Vector3(0f, 1f, 160f);
			}
			else
			{
				this.sonicCollider.center = new Vector3(0f, 1f, 145f);
			}
		}
		this.SetupParticlesForLaser();
	}

	// Token: 0x06000EF1 RID: 3825 RVA: 0x00072CE6 File Offset: 0x00070EE6
	public void SetFirstPersonMode(bool isFpsMode)
	{
		this.firstPersonMode = isFpsMode;
		this.EnableModelRender(!isFpsMode);
	}

	// Token: 0x06000EF2 RID: 3826 RVA: 0x00072CFC File Offset: 0x00070EFC
	private void EnableModelRender(bool render)
	{
		if (this.model == null)
		{
			this.model = base.transform.Find("raygun").gameObject;
		}
		foreach (Renderer renderer in this.model.GetComponentsInChildren<Renderer>())
		{
			renderer.enabled = render;
		}
	}

	// Token: 0x06000EF3 RID: 3827 RVA: 0x00072D60 File Offset: 0x00070F60
	private void SetupSoundsForProjectile()
	{
		this.firingAudioSource1.clip = SoundManager.This.playerRaygunProjFireSound;
	}

	// Token: 0x06000EF4 RID: 3828 RVA: 0x00072D77 File Offset: 0x00070F77
	private void SetupSoundsForLaser()
	{
		this.firingAudioSource2.clip = SoundManager.This.playerRaygunLaserSustainSound;
	}

	// Token: 0x06000EF5 RID: 3829 RVA: 0x00072D8E File Offset: 0x00070F8E
	private void SetupSoundsForSonic()
	{
		this.firingAudioSource1.clip = SoundManager.This.playerRaygunSonicFireSound;
		this.firingAudioSource2.clip = SoundManager.This.playerRaygunSonicSustainSound;
	}

	// Token: 0x06000EF6 RID: 3830 RVA: 0x00072DBA File Offset: 0x00070FBA
	private void PlayAuxiliarySound(AudioClip clip)
	{
		this.auxiliaryAudioSource.clip = clip;
		this.auxiliaryAudioSource.Play();
	}

	// Token: 0x06000EF7 RID: 3831 RVA: 0x00072DD4 File Offset: 0x00070FD4
	public void UpdateSounds()
	{
		PlayerRaygun.FiringMode firingMode = this.currentFiringMode;
		if (firingMode != PlayerRaygun.FiringMode.SingleFire)
		{
			if (firingMode != PlayerRaygun.FiringMode.Continuous)
			{
				if (firingMode == PlayerRaygun.FiringMode.Sonic)
				{
					this.SetupSoundsForSonic();
				}
			}
			else
			{
				this.SetupSoundsForLaser();
			}
		}
		else
		{
			this.SetupSoundsForProjectile();
		}
	}

	// Token: 0x06000EF8 RID: 3832 RVA: 0x00072E22 File Offset: 0x00071022
	public void SetScriptGrowColor(int r, int g, int b)
	{
		this.scriptGrowColor = new Color(Mathf.Clamp01((float)r / 255f), Mathf.Clamp01((float)g / 255f), Mathf.Clamp01((float)b / 255f));
		this.RefreshColors();
	}

	// Token: 0x06000EF9 RID: 3833 RVA: 0x00072E5C File Offset: 0x0007105C
	public void ClearScriptGrowColor()
	{
		this.scriptGrowColor = Color.clear;
		this.RefreshColors();
	}

	// Token: 0x06000EFA RID: 3834 RVA: 0x00072E6F File Offset: 0x0007106F
	public void SetScriptShrinkColor(int r, int g, int b)
	{
		this.scriptShrinkColor = new Color(Mathf.Clamp01((float)r / 255f), Mathf.Clamp01((float)g / 255f), Mathf.Clamp01((float)b / 255f));
		this.RefreshColors();
	}

	// Token: 0x06000EFB RID: 3835 RVA: 0x00072EA9 File Offset: 0x000710A9
	public void ClearScriptShrinkColor()
	{
		this.scriptShrinkColor = Color.clear;
		this.RefreshColors();
	}

	// Token: 0x06000EFC RID: 3836 RVA: 0x00072EBC File Offset: 0x000710BC
	public void SetScriptEnableRaygun(bool enable)
	{
		this.scriptEnableRaygun = enable;
	}

	// Token: 0x06000EFD RID: 3837 RVA: 0x00072EC5 File Offset: 0x000710C5
	public bool GetScriptEnableRaygun()
	{
		return this.scriptEnableRaygun;
	}

	// Token: 0x040013C4 RID: 5060
	public PlayerRaygun.FiringMode currentFiringMode;

	// Token: 0x040013C5 RID: 5061
	public static PlayerRaygun instance;

	// Token: 0x040013C6 RID: 5062
	[SerializeField]
	private GameObject model;

	// Token: 0x040013C7 RID: 5063
	[SerializeField]
	private MeshRenderer modelMeshRenderer;

	// Token: 0x040013C8 RID: 5064
	private GameObject reticuleUIObj;

	// Token: 0x040013C9 RID: 5065
	private RaygunReticule reticuleUI;

	// Token: 0x040013CA RID: 5066
	private Camera mainCamera;

	// Token: 0x040013CB RID: 5067
	private GameObject aimTargetObj;

	// Token: 0x040013CC RID: 5068
	[SerializeField]
	private Rigidbody rb;

	// Token: 0x040013CD RID: 5069
	private LayerMask aimMask;

	// Token: 0x040013CE RID: 5070
	private LayerMask projectileMask;

	// Token: 0x040013CF RID: 5071
	private LayerMask laserMask;

	// Token: 0x040013D0 RID: 5072
	private LayerMask sonicMask;

	// Token: 0x040013D1 RID: 5073
	private AnimationCurve expandingCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);

	// Token: 0x040013D2 RID: 5074
	private AnimationCurve retractingCurve = AnimationCurve.EaseInOut(1f, 1f, 0f, 0f);

	// Token: 0x040013D3 RID: 5075
	private Color shrinkColor;

	// Token: 0x040013D4 RID: 5076
	private Color growColor;

	// Token: 0x040013D5 RID: 5077
	private Color activeColor;

	// Token: 0x040013D6 RID: 5078
	private Gradient activeEmitterParticlesGradient;

	// Token: 0x040013D7 RID: 5079
	private Gradient singleFireEmitterParticlesGradient = new Gradient();

	// Token: 0x040013D8 RID: 5080
	private Gradient laserLineGradient = new Gradient();

	// Token: 0x040013D9 RID: 5081
	private Gradient laserParticlesGradient = new Gradient();

	// Token: 0x040013DA RID: 5082
	private Gradient sonicParticlesGradient = new Gradient();

	// Token: 0x040013DB RID: 5083
	[SerializeField]
	private LineRenderer line;

	// Token: 0x040013DC RID: 5084
	private float baseLineStartWidth = 0.15f;

	// Token: 0x040013DD RID: 5085
	private float baseLineEndWidth = 0.3f;

	// Token: 0x040013DE RID: 5086
	[SerializeField]
	private ParticleSystem emitterParticles;

	// Token: 0x040013DF RID: 5087
	[SerializeField]
	private ParticleSystem shotEmitterParticles;

	// Token: 0x040013E0 RID: 5088
	[SerializeField]
	private ParticleSystem sonicParticles;

	// Token: 0x040013E1 RID: 5089
	[SerializeField]
	private ParticleSystem chargeParticles;

	// Token: 0x040013E2 RID: 5090
	[SerializeField]
	private ParticleSystem impactParticles;

	// Token: 0x040013E3 RID: 5091
	[SerializeField]
	private GameObject impactParticlesObj;

	// Token: 0x040013E4 RID: 5092
	[SerializeField]
	private CapsuleCollider sonicCollider;

	// Token: 0x040013E5 RID: 5093
	private float baseSonicColliderRadius = 60f;

	// Token: 0x040013E6 RID: 5094
	private float playerScale = 1f;

	// Token: 0x040013E7 RID: 5095
	private bool firstPersonMode;

	// Token: 0x040013E8 RID: 5096
	private float sonicLengthMult = 0.5f;

	// Token: 0x040013E9 RID: 5097
	private bool isFiring;

	// Token: 0x040013EA RID: 5098
	private float polarityMagnitude = 0.5f;

	// Token: 0x040013EB RID: 5099
	private float currentCharge;

	// Token: 0x040013EC RID: 5100
	private List<GameObject> sonicAffectedObjects = new List<GameObject>();

	// Token: 0x040013ED RID: 5101
	private Dictionary<Transform, int> sonicAffectedRootTransforms = new Dictionary<Transform, int>();

	// Token: 0x040013EE RID: 5102
	private bool checkCurrentObjectsInFrustrum;

	// Token: 0x040013EF RID: 5103
	private Color scriptShrinkColor;

	// Token: 0x040013F0 RID: 5104
	private Color scriptGrowColor;

	// Token: 0x040013F1 RID: 5105
	private bool scriptEnableRaygun = true;

	// Token: 0x040013F2 RID: 5106
	[SerializeField]
	private AudioSource firingAudioSource1;

	// Token: 0x040013F3 RID: 5107
	[SerializeField]
	private AudioSource firingAudioSource2;

	// Token: 0x040013F4 RID: 5108
	[SerializeField]
	private AudioSource auxiliaryAudioSource;

	// Token: 0x0200029C RID: 668
	public enum FiringMode
	{
		// Token: 0x040013F6 RID: 5110
		SingleFire,
		// Token: 0x040013F7 RID: 5111
		Continuous,
		// Token: 0x040013F8 RID: 5112
		Sonic
	}
}
